import RankingAPI from '../../../../common/api/biosafety/ranking.api.js';
import doT from '../../../../../vendor/template/doT.js';
import { DictionaryType, requestDict } from "../../../../common/dictionary/dictionary-type.js";
import { uploadFile, requestFilePath, publicFileDraw, sliceFileName } from "../../../../common/api/file-request.js";

(function (window, document, $) {
    let _vm, timeIsShow = false, sort = false, _addressData = {}, list = [], time_interval = [], pigType = 0
    const datesTemplate = doT.template($('#dates-template').text());
    $(function () {
        $('body').attr('data-weui-theme', 'light'); //强制光明模式

        _initClick();
        getTime()
    });

    // 获取日期
    const getTime = () => {
        let arr = []
        for (let index = 0; index <= 3; index++) {
            arr.push(moment().add('-' + index, 'd').format("YYYY-MM-DD"))
        }
        // 默认今天日期
        $('#queryTime').text(moment().format("YYYY-MM-DD"))
        $('.times').empty().append(datesTemplate(arr));
    }

    // 点击事件
    const _initClick = () => {
        // 点击业务日期
        $('#times').on("click", function () {
            // 旋转图标
            $(this).find('i').css('rotate', timeIsShow ? "0deg" : "90deg")
            // 显示 下拉框
            $(".times").css("display", timeIsShow ? 'none' : 'block')
            // 点击改变状态
            timeIsShow = !timeIsShow;
        })

        // 点击下拉菜单选项
        $(document).on("click", '.dropdown_item', function (e) {
            e.stopPropagation();
            $(this).addClass('active').siblings().removeClass('active')
            $('.rankingContent').empty();
            // 关闭
            $('.dropdown').css('display', 'none')
            $('#times i').css('rotate', "0deg")
            // 控制显示和隐藏
            timeIsShow = false
            // 点击时间列表
            $('#queryTime').text($(this).data("val"))
        })

        $('#query-datas').on("click", function () {
            location.href = `./querypiglist.html`
        })
    }

})(window, document, jQuery)